<template>
  <el-container>
    <!-- Aside -->
    <el-aside width="200">
      <div class="logo"></div>
      <el-menu
        :default-active="$route.path"
        class="el-qf-menu"
        text-color="#4e5bf8"
        active-text-color="#E47833"
        :collapse="collapse"
      >
        <qf-sub-menu :sideMenu="sideMenu"></qf-sub-menu>
      </el-menu>
    </el-aside>
    <el-container>
      <!-- Header -->
      <el-header>
        <el-row type="flex" class="row-bg" justify="space-around">
          <el-col :span="6">
            <div class="grid-content left">
              <i
                @click="collapse = !collapse"
                :class="[
                  'iconfont',
                  collapse ? 'icon-zhankai-shousuo1' : 'icon-zhankai-shousuo',
                ]"
              ></i>
            </div>
          </el-col>
          <el-col :span="6">
            <div class="grid-content center">学员后台管理系统</div>
          </el-col>
          <el-col :span="6">
            <div class="grid-content right">
              <el-avatar shape="square" :size="40" :src="squareUrl"></el-avatar>
              <span>欢迎您:</span>
              &nbsp;
              <el-dropdown @command="command">
                <span class="nickname">{{ userInfo.nickname }}</span>
                <span class="el-dropdown-link">
                  <i class="el-icon-arrow-down el-icon--right"></i>
                </span>
                <el-dropdown-menu slot="dropdown">
                  <el-dropdown-item divided command="" class="iconfont icon-VIP"
                    >vip充值</el-dropdown-item
                  >
                  <el-dropdown-item
                    divided
                    command="users"
                    class="iconfont icon-zhanghaoxinxi"
                    >账号信息</el-dropdown-item
                  >
                  <el-dropdown-item
                    divided
                    command="product"
                    class="iconfont icon-wenzhanghuoke-"
                    >项目管理</el-dropdown-item
                  >
                  <el-dropdown-item
                    divided
                    @click.native="quit"
                    class="iconfont icon-tuichu2"
                    >退出</el-dropdown-item
                  >
                </el-dropdown-menu>
              </el-dropdown>
            </div>
          </el-col>
        </el-row>
      </el-header>
      <!-- Main -->
      <el-main>
        <el-breadcrumb separator="/">
          <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
          <el-breadcrumb-item v-for="bread in breadCrumb" :key="bread.name">{{
            bread.meta.name
          }}</el-breadcrumb-item>
        </el-breadcrumb>
        <router-view></router-view>
      </el-main>
    </el-container>
  </el-container>
</template>

<script>
import { mapState } from "vuex";
export default {
  data() {
    return {
      collapse: false,
    };
  },
  computed: {
    ...mapState(["userInfo", "sideMenu", "breadCrumb"]),
    squareUrl() {
      return this.userInfo.headimgurl
        ? this.userInfo.headimgurl
        : "https://cube.elemecdn.com/9/c2/f0ee8a3c7c9638a54940382568c9dpng.png";
    },
  },
  methods: {
    quit() {
      console.log(123);
      localStorage.removeItem("qf-token");
      this.$router.push("/login");
      location.reload();
    },
    // 右上角用户下拉菜单
    command(routeName) {
      if (routeName) {
        this.$router.push({ name: routeName });
      }
    },
  },
  mounted() {
    // this.$store.dispatch("GET_MENULIST");这边有出问题，渲染了两次列表
  },
};
</script>
<style lang="less" scoped>
// .el-header,
// .el-footer {
//   background-color: #b3c0d1;
//   color: #333;
//   text-align: center;
// }

// .el-aside {
//   background: linear-gradient(135deg, #4c67ff, #5635df);

//   color: #333;
//   text-align: center;
//   // line-height: 200px;
//   .logo {
//     min-height: 60px;
//     background-image: url(http://chst.vip:8081/stu2/img/logo.be8bbddf.png);
//     background-size: 80%;
//     background-repeat: no-repeat;
//     background-position-y: center;
//     background-position-x: 40%;
//   }
//   .subMenu {
//     text-align: left;
//   }
//   /deep/ .el-qf-menu:not(.el-menu--collapse) {
//     width: 200px;
//     min-height: 500px;
//   }
// }

// .el-main {
//   background-color: #fff;
//   color: #333;
//   text-align: center;
//   padding: 20px;
//   border-left: 1px solid green;
// }

// .el-container {
//   margin-bottom: 40px;
//   height: 100%;
// }

// .el-container:nth-child(5) .el-aside,
// .el-container:nth-child(6) .el-aside {
//   line-height: 260px;
// }

// .el-container:nth-child(7) .el-aside {
//   line-height: 320px;
// }

// // .el-header
// .el-header {
//   border-left: 1px solid green;
//   padding: 0;
//   line-height: 60px;
//   min-height: 60px;
//   color: #fff;

//   .el-row {
//     padding: 0 10px;
//     margin-bottom: 20px;
//     justify-content: space-between;
//     &:last-child {
//       margin-bottom: 0;
//     }
//   }
//   .el-col {
//     border-radius: 4px;
//   }

//   .grid-content {
//     border-radius: 4px;
//     min-height: 36px;
//     text-align: left;
//   }
//   .left {
//     .iconfont {
//       font-size: 35px;
//     }
//   }
//   .grid-content.right {
//     display: flex;
//     font-size: 16px;
//     /deep/.el-avatar {
//       margin-top: 9px;
//       margin-right: 3px;
//     }

//     span {
//       margin-left: 5px;
//     }
//     > span:nth-of-type(2) {
//       color: deepskyblue;
//       text-decoration: underline;
//     }
//     > span:nth-of-type(3) {
//       color: #ff69b4;
//     }
//   }
//   .center {
//     font-size: 18px;
//     font-weight: 800;
//   }
//   .row-bg {
//     height: 100%;
//     background: linear-gradient(135deg, #4c67ff, #5635df);
//   }
// }
//
</style>
<style scoped lang="less">
.el-header {
  min-height: 60px !important;
  background: linear-gradient(135deg, #4c67ff, #5635df);
  color: #fff;
  font-weight: bolder;
  text-align: center;
  // line-height: 60px;
  line-height: 40px;
  .left {
    text-align: left;

    i {
      font-size: 30px;
      cursor: pointer;
    }
  }
  .center {
    font-size: 30px;
  }
  .right {
    // 头部下拉菜单样式
    /deep/.el-dropdown-link {
      cursor: pointer;
      color: #409eff;
    }
    /deep/.el-icon-arrow-down {
      font-size: 12px;
    }
  }
  .el-avatar {
    vertical-align: middle;
    margin-right: 10px;
  }
  .quit {
    color: deeppink;
    text-decoration: underline;
    cursor: pointer;
  }
  .nickname {
    margin-left: 5px;
    color: deepskyblue;
  }
}

.el-aside {
  background: linear-gradient(135deg, #4c67ff, #5635df);

  color: #333;
  text-align: center;
  // line-height: 200px;
  .logo {
    min-height: 60px;
    background-image: url(http://chst.vip:8081/stu2/img/logo.be8bbddf.png);
    background-size: 80%;
    background-repeat: no-repeat;
    background-position-y: center;
    background-position-x: 40%;
  }
  .subMenu {
    text-align: left;
  }
  /deep/ .el-qf-menu:not(.el-menu--collapse) {
    width: 200px;
    min-height: 500px;
  }
}

.el-main {
  background-color: #fff;
  color: #333;
  text-align: center;
  // line-height: 160px;
  .el-breadcrumb {
    margin-bottom: 30px;
  }
}

.el-container {
  margin-bottom: 40px;
  height: 100%;
}

.el-container:nth-child(7) .el-aside {
  line-height: 320px;
}
// 顶栏laout
.el-row {
  margin-bottom: 20px;
  &:last-child {
    margin-bottom: 0;
  }
}
.el-col {
  border-radius: 4px;
}

.grid-content {
  border-radius: 4px;
  min-height: 36px;
}
.row-bg {
  padding: 10px 0;
}
</style>
